﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using Fuse8.ContentManagementFramework.SystemFacade.Globalization;

namespace Fuse8.ContentManagementFramework.Administration.Attributes
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public class GlobalizedDisplayAttribute : DisplayNameAttribute
    {
        private readonly string _name;
        private readonly string _domain;

        public GlobalizedDisplayAttribute(string name, string domain)
        {
            _name = name;
            _domain = domain;
        }

        public override string DisplayName
        {
            get { return GlobalizationFacade.Current.WithDomain(_domain, CultureInfo.CurrentUICulture).GetText(_name); }
        }
    }
}